package com.qf.mvc2202.controller;

import com.qf.mvc2202.entity.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
@Controller
@RequestMapping("/param")
public class ParamController {
    @RequestMapping("/test1")
    public String test1(Integer id,
                        String name,
                        Boolean gender,
                        @DateTimeFormat(pattern = "yyyy-MM-dd HH-mm-ss") Date birth){
        System.out.println(id);
        System.out.println(name);
        System.out.println(gender);
        System.out.println(birth);
        return "hello";
    }
    @RequestMapping("/test2")
    public String testParam1(User user){
        System.out.println(user);
        return "hello";
    }
    @RequestMapping("/test3")
    public String testParam3(String[] hobby){
        for(String h:hobby){
            System.out.print(h+" ");
        }
        return "hello";
    }
    @RequestMapping("/get/{id}")
    public String test4(@PathVariable("id") Integer id){
        System.out.println(id);
        return "hello";
    }
}
